package com.csu.cphone.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csu.cphone.dao.MaintainSelectAnswerMapper;
import com.csu.cphone.pojo.MaintainSelectAnswerPojo;
import com.csu.cphone.service.MaintainSelectAnswerService;

/**
 * @项目名称：cphone
 * @类名称：MaintainSelectAnswerServiceImpl
 * @类描述：
 * @创建人：Tangc
 * @创建时间：2017年12月7日 下午4:15:57
 * @company:
 */
@Service
public class MaintainSelectAnswerServiceImpl implements MaintainSelectAnswerService
{

    @Autowired
    private MaintainSelectAnswerMapper maintainSelectAnswerMapper;

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#deleteById(java.lang.Integer)
     */
    @Override
    public Integer deleteById(Integer maintainProblemId)
    {
        return maintainSelectAnswerMapper.deleteById(maintainProblemId);
    }

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#queryList(java.lang.Integer,
     *      java.lang.Integer, java.lang.String)
     */
    @Override
    public List<MaintainSelectAnswerPojo> queryList(Integer pageSize, Integer startIndex, String order,
            String maintainOrderSn)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("pageSize", pageSize);
        map.put("startIndex", startIndex);
        map.put("order", order);
        if (maintainOrderSn != null)
        {
            map.put("maintainOrderSn", maintainOrderSn);
        }
        return maintainSelectAnswerMapper.queryList(map);
    }

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#count()
     */
    @Override
    public Integer count(String maintainOrderSn)
    {
        return maintainSelectAnswerMapper.count(maintainOrderSn);
    }

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#queryById(java.lang.Integer)
     */
    @Override
    public MaintainSelectAnswerPojo queryById(Integer maintainProblemId)
    {
        return maintainSelectAnswerMapper.selectById(maintainProblemId);
    }

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#update(com.csu.cphone.pojo.MaintainSelectAnswerPojo)
     */
    @Override
    public Integer update(MaintainSelectAnswerPojo selectPojo)
    {
        return maintainSelectAnswerMapper.update(selectPojo);
    }

    /**
     * @see com.csu.cphone.service.MaintainSelectAnswerService#add(java.lang.Integer,
     *      java.lang.String, java.lang.Integer, java.lang.Integer,
     *      java.lang.Double)
     */
    @Override
    public MaintainSelectAnswerPojo add(Integer maintainPhoneId, String maintainOrderSn, Integer maintainProblemId,
            Integer maintainProblemSelectId, Double cost)
    {
        MaintainSelectAnswerPojo maintainSelectAnswer = new MaintainSelectAnswerPojo();
        maintainSelectAnswer.setCost(cost);
        maintainSelectAnswer.setMaintainOrderSn(maintainOrderSn);
        maintainSelectAnswer.setMaintainPhoneId(maintainPhoneId);
        maintainSelectAnswer.setMaintainProblemId(maintainProblemId);
        maintainSelectAnswer.setMaintainProblemSelectId(maintainProblemSelectId);
        maintainSelectAnswerMapper.insert(maintainSelectAnswer);
        return maintainSelectAnswer;
    }

}
